function ajax(url) {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest();
        xhr.open('GET', url);
        xhr.responseType = 'json';
        xhr.onload = function () {
            if (this.status === 200) {
                resolve(this.response);
            } else {
                reject(new Error(this.statusText));
            }
        };
        xhr.send();
    });
}


async function main() {

    try {
        const res1 = await ajax('../package.json');

        console.log('res1', res1);

        const res2 = await ajax('../package-lock.json');
        
        console.log('res2', res2);
    } catch(e) {
        console.log(e);
    }
}

const promise = main();

promise.then(res1 => {
    console.log('then = res1', res1);
}).then(res2 => {
    console.log('then = res2', res2);
});

console.log('promise', promise)
